package com.uwo.house.service.serviceImpl;

import com.uwo.house.beans.request.HomePageReq;
import com.uwo.house.beans.request.InfoAboutReq;
import com.uwo.house.beans.response.*;
import com.uwo.house.dao.CustomDao;
import com.uwo.house.service.ICustomService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * Created by cyn1c on 2017/7/23.
 */
@Service
public class CustomService implements ICustomService {
    @Autowired
    CustomDao customDao;
    public List<CustomPackageResp> getPackagesByStyle(String decorationStyle){
        return customDao.getPackagesByStyle(decorationStyle);
    }

    public List<CustomScheduleResp> getConstructionSchedule(String userId){
        return this.customDao.getConstructionSchedule(userId);
    }

    public List<UserOrderResp> getUserOrder(String userId){
        return this.customDao.getUserOrder(userId);
    }

    public List<HomePageResp> getHomePages(){
        return this.customDao.getHomePages();
    }

    public List<ContractPicResp>getContractPic(){
        return this.customDao.getContractPic();
    }

    public int modifyHomePages(HomePageReq homePageReq) {
        return this.customDao.modifyHomePages(homePageReq);
    }

    public int deleteHomePages(){
        return this.customDao.deleteHomePages();
    }

    public int addHomePages(HomePageReq homePageReq){
        return this.customDao.addHomePages(homePageReq);
    }

    public HomePageResp getHomePagesDetail(int id){
        return this.customDao.getHomePagesDetail(id);
    }

    public int addContractPic(String contractPic) {
        int result2 = 2;
        try {
            customDao.deleteContractPic();
        } catch (Exception e) {
            result2 = 1;
        }
        int result1 = customDao.addContractPic(contractPic);
        if (result2 != 1 && result1 == 1) {
            return 1;
        }
        return 2;
    }

}
